package com.jiang.myfm.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.jiang.myfm.R;
import com.jiang.myfm.entities.guobobean.Content;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2016/12/8.
 */
public class Find3adaptercon extends BaseAdapter {
    private Context context;
    private List<Content> list;

    public Find3adaptercon(Context context, List<Content> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
         return list!=null?list.size():0;
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.find_3_include,parent,false);
            holder=new ViewHolder();
            holder.iv= (ImageView) convertView.findViewById(R.id.iv);
            holder.tv_name= (TextView) convertView.findViewById(R.id.tv_name);
holder.tv_showname= (TextView) convertView.findViewById(R.id.tv_showname);
            holder.tv_number= (TextView) convertView.findViewById(R.id.tv_number);
        convertView.setTag(holder);
        }else {
            holder= (ViewHolder) convertView.getTag();
        }
        Content content=list.get(position);
        holder.tv_name.setText(content.getName());
        holder.tv_showname.setText(content.getProgramName());
        holder.tv_number.setText(content.getPlayCount());
        Picasso.with(context).load(content.getCoverSmall()).into(holder.iv);
        return convertView;
    }
    public class  ViewHolder{
private ImageView iv;
 private        TextView tv_name,tv_showname,tv_number;
    }
}
